A scatterplot displays the relationship between 2 numeric variables. For each data point, the value of its first variable is represented on the X axis, the second on the Y axis.
<!-- Include the CanvasXpress library in your HTML file -->
<link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
<script src="https://www.canvasxpress.org/canvasXpress.min.js"></script>
<!-- Create a canvas element for the chart with the desired dimensions -->
<div>
<canvas id="canvasId" width="600" height="600"</canvas>
</div>
<!-- Create a script to initialize the chart -->
<script>
<!-- Create the data for the graph -->
var data = {
"y" : {
"data" : [
[6.47,4.03],
[6.13,3.76],
[6.19,3.77],
[4.89,3.34],
[5.63,3.47],
[4.52,2.92],
[5.89,3.2],
[4.79,2.71],
[3.53,3.53],
[6.08,4.51],
[4.02,4.56]
],
"smps" : ["Alcohol","Tobacco"],
"vars" : ["North","Yorkshire","Northeast","East Midlands","West Midlands","East Anglia","Southeast","Southwest","Wales","Scotland","Northern Ireland"]
}
}
<-- Create the configuration for the graph -->
var config = {
"citation":"Moore, David S., and George P. McCabe (1989). Introduction to the Practice of Statistics, p. 179.",
"decorations":{
"marker":[
{
"sample":[
"Alcohol",
"Tobacco"
],
"text":"Maybe an Outlier?",
"variable":"Northern Ireland",
"x":0.45,
"y":0.18
}
]
},
"graphType":"Scatter2D",
"showTransition":"false",
"theme":"CanvasXpress",
"title":"Average weekly household spending, in British pounds, on tobacco products\\nand alcoholic beverages for each of the 11 regions of Great Britain.",
"xAxis":[
"Alcohol"
],
"yAxis":[
"Tobacco"
]
}
<!-- Call the CanvasXpress function to create the graph -->
var cX = new CanvasXpress("canvasId", data, config);
</script>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/cX-alcoholtobaccot-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
citation="Moore, David S., and George P. McCabe (1989). Introduction to the Practice of Statistics, p. 179.",
decorations=list(marker=list(list(sample=list("Alcohol", "Tobacco"), text="Maybe an Outlier?", variable="Northern Ireland", x=0.45, y=0.18))),
graphType="Scatter2D",
showTransition=FALSE,
theme="CanvasXpress",
title="Average weekly household spending, in British pounds, on tobacco products\nand alcoholic beverages for each of the 11 regions of Great Britain.",
xAxis=list("Alcohol"),
yAxis=list("Tobacco")
)
Create New Page